<template>
  <div class="floor">
    <div class="block " style="background-color:#fff;padding-top:12px;padding-bottom:22px" v-for="(item,index) in items"
         :key="index">
      <div class="pendbox commoditybox">
        <div class="header">
          <div class="title">
            {{item.floor_name}}
            <span class="subtitle">{{item.floor_desc}}</span>
          </div>
          <div class="more" @click="onMore(item)">更多</div>
        </div>
        <div @click="onClickImage(item)">
          <img class="streamer" :src="item.floor_image">
        </div>
        <div class="grid grid-gutter">
          <div v-for="(subItem,subIndex) in item.goods_list" :key="subIndex" class="grid-1-2">
            <div class="item" @click="onClick(subItem)">
              <div class="supplier">
                <chimage class="imgge" :src="subItem.goods_image"></chimage>
                <div class="supplier-text">{{textSupplier(subItem.supplier_id)}}</div>
              </div>
              <div class="title">{{subItem.goods_name}}</div>
              <div class="list-price">
                <div class="price newPrice">{{subItem.price_alias}}￥{{subItem.goods_price}}</div>
                <div class="shop-btn" @click.stop="onAddCart(subItem.goods_id, subItem.goods_sku, subItem.goods_mininum)">
                  <img :src="require('@/assets/img/icon_item_gwc.png')"/>
                </div>
              </div>
              <div class="list-price">
                <div class="price oldPrice">{{subItem.price_alias_market}}￥{{subItem.goods_price_market}}</div>
              </div>
              <div class="list-price">
                <div v-if="discountClass(subItem.goods_price_discount)" class="discount" :class="discountClass(subItem.goods_price_discount)">
                  <chimage class="icon" :src="require('@/assets/img/icon_discount.png')"></chimage>
                  <span>{{subItem.goods_price_discount}}%</span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import shop from '../../mixin/shop'
  export default {
    name: 'mallFloor',
    mixins: [shop],
    props: {
      items: Array
    },
    methods: {
      onClick (item) {
        this.$router.push({ name: 'mallInfo', params: { goodsId: item.goods_id } })
      },
      onMore (item) {
        this.$router.push({
          name: 'mallFloor',
          params: { floorId: item.floor_id }
        })
      },
      onClickImage (item) {
        this.$router.push({ name: 'mallInfo', params: { goodsId: item.floor_image_goods } })
      }
    }
  }
</script>

<style lang="less" scoped>

  .floor {

    margin-bottom: 5px;

    .block {
      padding: 10px;
      margin-top: 5px;
      background: #fff;
    }
  }

  .streamer {
    max-height: 250px;
    width: 100%;
    display: block;
    background-color: #fff;
    border-radius: 5px;
  }

  .pendbox {
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .title {
        font-size: 15px;
        color: #351009;
        line-height: 24px;
      }

      .subtitle {
        font-size: 12px;
        color: #848484;
      }

      .more {
        color: #a8a8a8;
        font-size: 12px;
      }
    }
  }

  .commoditybox {
    background-color: #fff;

    .streamer {
      margin-top: 10px;
      margin-bottom: 10px;
    }

    .item {
      display: block;
      background-color: #ffffff;

      .imgge {
        background-color: #ffffff;
        height: auto;
        width: 100%;
        background-size: contain;
        display: block;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }

      .supplier {
        height: 158px;
        overflow: hidden;
      }

      .title {
        margin-top: 12px;
        font-size: 12px;
        line-height: 17px;
        /*color: #737373;*/
        color: #575757;
        height: 34px;
        text-overflow: ellipsis;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }

      .bagbar {
        display: flex;
        margin-left: -10px;
        margin-top: 8px;

        .bag {
          padding-left: 6px;
          padding-right: 6px;
          font-size: 10px;
          height: 14px;
          line-height: 14px;
          display: block;
          margin-left: 12px;
          border: 1px solid transparent;
        }

        .bag-ticket {
          border-color: #fd0002;
        }

        .bag-active {
          border-color: #920882;
        }
      }

      .pricebar {
        // margin-top: 8px;
        display: flex;

        .price {
          font-size: 14px;
          line-height: 20px;
          color: #fe0000;
          flex: 1;
        }

        .icon {
          height: 15px;
          width: 15px;
          display: block;
          border-radius: 8px;
          margin-left: 12px;
        }
      }
    }
  }

  .commoditybox-no {
    background-color: transparent;

    .item {
      padding: 12px;
    }
  }

  .grid-1-2 {
    padding-top: 15px !important;
  }
</style>
